from flask_migrate import Migrate,MigrateCommand
from flask_script import Manager
from info import create_app,db
from info.models import User

app = create_app("develop")
manager = Manager(app)
# 创建迁移对象
Migrate(app,db)
# 将需要转移的对象转移
manager.add_command('mysql', MigrateCommand)
# 添加转移命令，mysql是用来描述转移信息的


@manager.option("-n",'--name',dest='name')
@manager.option("-p",'--password',dest='password')
def create_super_user(name,password):
    user = User()
    user.mobile = name
    user.nick_name = name
    user.password = password
    user.is_admin = True
    db.session.add(user)
    db.session.commit()

if __name__ == '__main__':
    manager.run()

